using System;
using System.Collections.Generic;
using System.Text;

namespace GPSCore
{
    /// <summary>
    /// Azimuth from north
    /// </summary>
    public class Azimuth : Angle, IComparable<Azimuth>, IComparer<Azimuth> , IEquatable<Azimuth>
    {
        #region constructors

        /// <summary>
        /// Azimuth base constructor
        /// </summary>
        public Azimuth():base()
        {
            base.Behaviours = AngleBehaviours.AutoNormalization;
        }

        /// <summary>
        /// Create an Azimuth Object starting from a Cardinal Direction
        /// </summary>
        /// <param name="direction"></param>
        public Azimuth(CardinalDirection direction)
        {
            ///TODO: Implement the carinal direction  

            base.Behaviours = AngleBehaviours.AutoNormalization;
            base._normalize();
            base._splitData();
        }

        /// <summary>
        /// Build a Azimuth from an Angle
        /// </summary>
        /// <param name="Angle"></param>
        public Azimuth(Angle Angle)
            : base(Angle)
        {
            base.Behaviours = AngleBehaviours.AutoNormalization;
            base._normalize();
            base._splitData();       
        }

        /// <summary>
        /// Build an Azimuth from a double value including information about H,M,S.dddd
        /// </summary>
        /// <param name="DecimalDegrees"></param>
        public Azimuth(double DecimalDegrees)
            : base(DecimalDegrees)
        {
            base.Behaviours = AngleBehaviours.AutoNormalization;
            base._normalize();
            base._splitData();
        }
        
        
        /// <summary>
        /// Build a Azimuth from an integer value of Degrees and a decimal value of Minutes
        /// </summary>
        /// <param name="IntDegrees"></param>
        /// <param name="DecimalMinutes"></param>
        public Azimuth(int IntDegrees, double DecimalMinutes)
            : base(IntDegrees, DecimalMinutes)
        {
            base.Behaviours = AngleBehaviours.AutoNormalization;
            base._normalize();
            base._splitData();       
        }

        
        /// <summary>
        /// Build a Azimuth from a integer value of Degrees an integer Value of Minutes and a decimal value of Seconds
        /// </summary>
        /// <param name="IntDegrees"></param>
        /// <param name="IntMinutes"></param>
        /// <param name="DecimalSeconds"></param>
        public Azimuth(int IntDegrees, int IntMinutes, double DecimalSeconds)
            : base(IntDegrees, IntMinutes , DecimalSeconds)
        {
            base.Behaviours = AngleBehaviours.AutoNormalization;
            base._normalize();
            base._splitData();       
        }


        #endregion

        #region IComparable<Azimuth> Members

        int IComparable<Azimuth>.CompareTo(Azimuth other)
        {
            if (this._value > other._value)
            {
                return 1;
            }
            else
            {
                if (this._value < other._value)
                {
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }

        #endregion

        #region IComparer<Azimuth> Members

        int IComparer<Azimuth>.Compare(Azimuth x, Azimuth y)
        {
            if (x._value > y._value)
            {
                return 1;
            }
            else
            {
                if (x._value < y._value)
                {
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }

        #endregion

        #region IEquatable<Azimuth> Members

        /// <summary>
        /// Check the Azimuth Value
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(Azimuth other)
        {
            if (this._value.Equals(other._value))
                return true;
            else
                return false;
        }

        #endregion
    }
}
